package lab.gene.service.impl;

import java.util.Date;
import java.util.List;

import lab.gene.dao.GeneAmpliconPCRDAO;
import lab.gene.dao.GeneDAO;
import lab.gene.pojo.Gene;
import lab.gene.pojo.GeneAmpliconPCR;
import lab.gene.service.GeneAmpliconPCRService;
import lab.user.dao.UserDAO;
import lab.user.pojo.User;

public class GeneAmpliconPCRServiceImpl implements GeneAmpliconPCRService {

	@Override
	public GeneAmpliconPCR getGeneAmpliconPCRByNameAndType(String geneName,
			String type) {
		// TODO Auto-generated method stub
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		GeneAmpliconPCRDAO dao = new GeneAmpliconPCRDAO();
		GeneAmpliconPCR result = dao.getGeneAmpliconPCRByNameAndType(g, type);		
		return result;
	}

	@Override
	public void addGeneAmpliconPCR(String geneName, String type, String strain, Date recordDate, int exsize, String seqConfirmed, String comments, String userName){
		// TODO Auto-generated method stub
		UserDAO udao = new UserDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		User u = udao.getUser(userName);
		GeneAmpliconPCRDAO dao = new GeneAmpliconPCRDAO();
		GeneAmpliconPCR gm = new GeneAmpliconPCR();
		gm.setComments(comments);
		gm.setDateModified(new Date());
		gm.setExsize(exsize);
		gm.setGene(g);
		gm.setRecordDate(recordDate);
		gm.setSeqConfirmed(seqConfirmed);
		gm.setStrain(strain);
		gm.setType(type);
		gm.setUser(u);
		dao.addGeneAmpliconPCR(gm);

	}

	@Override
	public List<GeneAmpliconPCR> getGeneAmpliconPCRHistory(String geneName, String type) {
		List<GeneAmpliconPCR> g = null;
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		GeneAmpliconPCRDAO dao = new GeneAmpliconPCRDAO();
		g = dao.getGeneAmpliconPCRHistory(gene, type);
		return g;
	}

}
